package com.spring.sunflower.dialog;

import android.app.Activity;
import android.content.Intent;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.enums.PopupAnimation;
import com.spring.sunflower.R;
import com.spring.sunflower.common.WalletActivity;

/**
 * Created by Kevin on 2021/9/1<br/>
 * <p>
 * Describe:<br/>
 */
public class NoticeDialogUtils {
    private static NoticeDialogUtils mInstance;

    public static NoticeDialogUtils getInstance() {
        if (mInstance == null) {
            synchronized (NoticeDialogUtils.class) {
                if (mInstance == null) {
                    mInstance = new NoticeDialogUtils();
                }
            }
        }
        return mInstance;
    }

    public void show(Activity context, String title,String desc) {
        NoticeDialog dialog = new NoticeDialog(context, new OnPermissionIntroClickListener() {
            @Override
            public void onClickCancel() {

            }

            @Override
            public void onClickOK() {
                Intent intent = new Intent(context, WalletActivity.class);
                context.startActivity(intent);
            }
        });
        dialog.setOnCreateViewListener(new NoticeDialog.OnCreateViewListener() {
            @Override
            public void onCreateView() {
                TextView tv = dialog.findViewById(R.id.tv);
                TextView tvTitle = dialog.findViewById(R.id.tvTitle);
                TextView tvDesc = dialog.findViewById(R.id.tvDesc);
                tvTitle.setText(title);
                tvDesc.setText(desc);
            }
        });
        dialog.setHeadTitle("温馨提醒");
        dialog.setDescColor(ContextCompat.getColor(context,R.color.red_2));
        dialog.setOKText("去充值");
        new XPopup.Builder(context)
                .popupAnimation(PopupAnimation.ScaleAlphaFromCenter)
                .isRequestFocus(false)
                .dismissOnTouchOutside(false)
                .asCustom(dialog)
                .show();
    }
}
